<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head lang="zh-CN">
    <base href="<%=basePath%>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户资料完善</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
  	<div class="container-fluid">
      <div class="row">
      		<input type="hidden" id="openid" name="openid" value="${openid}">
		    <table border="0px" width="100%" height="100%">
		    	<tr height="10%" align="center">
		    		<td><span style="font-size: 15px;color: #60b6e6;">请填写正确的小区以供后期刷脸开门使用</span></td>
		    	</tr>
		    	<tr height="20%" align="center">
		    		<td>
		    			<div>
					        <select  class='prov' id='prov' onchange='changeCity()' style="height: 30px; width:30%;  border-radius: 30px; ">
					            <option  value=''>--请选择小区--</option>
					        </select>
					        &nbsp;&nbsp;
					        <select  class='city' id='city' style="height: 30px; border-radius: 30px; width:30%;">
					            <option  value=''>--请选择楼栋--</option>
					        </select>
					    </div>
		    		</td>
		    	</tr>
		    	<tr height="5%">
		    		<td>
		    			<input type="hidden" id="nickname" value="${nickname}">
		    			<input type="hidden" id="mobile" value="${mobile}">
		    			<input type="hidden" id="uploadImg" value="${uploadImg}">
		    		</td>
		    	</tr>
		    	<tr height="65%">
		    		<td align="center">
		    			<button type="button" onclick="button()" style="width: 250px; height: 50px; border-radius: 30px; background-color:#27a2f0;color: #ffffff">确定</button>
		    		</td>
		    	</tr>
		    </table>
    	</div>
    </div>
</body>
<script type="text/javascript" src="jquery/1.9.1/jquery.min.js"></script> 
<script>
		var province=document.getElementById("prov");
        var city=document.getElementById("city");
        //动态载入所有物业小区
    	$.ajax({
    		url:"<%=path%>/l/showAll",
    		type:"get",
    		success:function(res){
    			var json=JSON.parse(res);
		            for(var i=0;i<json.list.length;i++){
		                province.options[i+1]=new Option(json.list[i].address,json.list[i].address);
		       		}
    			} 
    	});
        //选中小区之后，根据小区名称动态载入相应楼栋
        function changeCity(){
        	if(province.selectedIndex == 0){
        		//清空上次的选项
		        city.options.length=0;
        		city.options[0]= new Option("--请选择楼栋--",'');
        	}else{
	        	$.ajax({
	    		url:"<%=path%>/l/showUnit",
	    		data:{
	    			address:province.value
	    		},
	    		type:"get",
	    		success:function(res){
	    			var json=JSON.parse(res);
	    			//清空上次的选项
		            city.options.length=0;
	             	for(var i=0;i<json.list.length;i++){
	                	city.options[i]=new Option(json.list[i].number,json.list[i].number);
	            	}
				}
	    	});
        }
     }
     	function button(){
			var address=document.getElementById("prov").value;
			var dong=document.getElementById("city").value;
			var nickname=document.getElementById("nickname").value;
			var mobile=document.getElementById("mobile").value;
			var openid=document.getElementById("openid").value;
			var uploadImg=document.getElementById("uploadImg").value;
			console.log(address+"\t"+dong+"\t"+nickname+"\t"+mobile);
			if(address==""){
				alert("小区选择不能为空");
			}else  if(dong == ""){
				alert("楼栋选择不能为空");
			}else{
				window.location.href="<%=path%>/u/JumpuserInformation?address="+address+"&dong="+dong+"&nickname="+nickname+"&mobile="+mobile+"&openid="+openid+"&uploadImg="+uploadImg;
			}
		}
    </script>
</html>
